const express = require("express")
const router = express.Router()

// router.use(function timeLog(req, res, next) {
//     console.log('Time: ', Date.now())
//     //模块路由中检测是否携带了 token
//     if (!req.auth) {
//         return res.send({
//             status: 403,
//             message: "缺少token"
//         });
//     }
//     next()
// })
const multipart = require('connect-multiparty');
// 引入控制层
const assigController = require("../controllers/assigController")
const { body, query } = require("express-validator")

// 引入中间件
const checkPermission = require('../middleware/checkPermission');
const auth = require('../middleware/auth');

router.post('/add', auth, checkPermission("homework_search_add"), assigController.add_c)
router.get('/del_f', auth, checkPermission("homework_search_delete"), assigController.del_f)
router.get('/start', auth, checkPermission("homework_search_delete"), assigController.start)
router.get('/del_t', auth, checkPermission("homework_search_delete"), assigController.del_t)
router.get('/get', auth, checkPermission("homework_search_list"), assigController.get)
router.post('/set', auth, checkPermission("homework_search_edit"), assigController.set)
router.get('/list', auth, checkPermission("homework_search_list"), assigController.list)
// 上传图片--单个图片--路由
// 定义路由处理文件上传请求
router.post('/upload', multipart(), auth, checkPermission("homework_search_edit"), assigController.uploads);
router.post('/unupload', multipart(), auth, checkPermission("homework_search_edit"), assigController.deleteImage);
router.get('/student_list', auth, checkPermission("homework_search_set"), assigController.student_list)
router.post('/correct', auth, checkPermission("homework_search_set"), assigController.correct)
router.get('/table', assigController.homework_table)
router.get('/sub_trend', assigController.sub_trend)
router.get('/difficulty', assigController.difficulty)
router.get('/allwork', checkPermission("homework_search_list"), assigController.allwork)
module.exports = router